#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;
const int N = 30;
string arr[N];
int n;

bool cmp(string& s1, string& s2)
{
    return s1 + s2 > s2 + s1;
}
int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> arr[i];
    sort(arr + 1, arr + 1 + n, cmp);
    for (int i = 1; i <= n; i++) cout << arr[i];
    return 0;
}